<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.10.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>common_util: src/common_util/sysutil.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">common_util
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.10.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_2961cad218251a7c35c6867350b80887.html">common_util</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle"><div class="title">sysutil.h</div></div>
</div><!--header-->
<div class="contents">
<a href="sysutil_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span> </div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno">   19</span><span class="preprocessor">#pragma once</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno">   20</span> </div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span><span class="preprocessor">#include &lt;cstdint&gt;</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span> </div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno">   24</span><span class="keyword">namespace </span>cutl</div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span>{</div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span> </div>
<div class="foldopen" id="foldopen00031" data-start="{" data-end="};">
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"><a class="line" href="sysutil_8h.html#aecaf674e04f64f60fd66feab407c606d">   31</a></span>    <span class="keyword">enum class</span> <a class="code hl_enumeration" href="sysutil_8h.html#aecaf674e04f64f60fd66feab407c606d">endian</a></div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno">   32</span>    {</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span>        <a class="code hl_enumvalue" href="sysutil_8h.html#aecaf674e04f64f60fd66feab407c606daaae6635e044ac56046b2893a529b5114">little</a>,</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span>        <a class="code hl_enumvalue" href="sysutil_8h.html#aecaf674e04f64f60fd66feab407c606dad861877da56b8b4ceb35c8cbfdf65bb4">big</a>,</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span>    };</div>
</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno">   38</span> </div>
<div class="foldopen" id="foldopen00043" data-start="{" data-end="};">
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"><a class="line" href="sysutil_8h.html#a74208522103f8b280572279e56105242">   43</a></span>    <span class="keyword">enum class</span> <a class="code hl_enumeration" href="sysutil_8h.html#a74208522103f8b280572279e56105242">os_platform</a></div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno">   44</span>    {</div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span>        <a class="code hl_enumvalue" href="sysutil_8h.html#a74208522103f8b280572279e56105242a4c7cfa22ccbb49a0418d12bdb8694bfb">os_windows</a>,</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno">   48</span>        <a class="code hl_enumvalue" href="sysutil_8h.html#a74208522103f8b280572279e56105242a776a1d886fdbbb04b1a8764fd3d41c9e">os_macos</a>,</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno">   50</span>        <a class="code hl_enumvalue" href="sysutil_8h.html#a74208522103f8b280572279e56105242aaf0e42c7c50c918d4570544ca7fad65f">os_linux</a>,</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span>        <a class="code hl_enumvalue" href="sysutil_8h.html#a74208522103f8b280572279e56105242a0f8ec0e3af19b871d9014e5109e5072a">os_unix</a>,</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno">   54</span>        <a class="code hl_enumvalue" href="sysutil_8h.html#a74208522103f8b280572279e56105242ab6363d75c866dbc9675af5f48ebc1fcc">os_unknown</a>,</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno">   55</span>    };</div>
</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno">   56</span> </div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"><a class="line" href="sysutil_8h.html#a19eb0a17bd5a89ecbbf7c5d267923402">   62</a></span>    <a class="code hl_enumeration" href="sysutil_8h.html#a74208522103f8b280572279e56105242">os_platform</a> <a class="code hl_function" href="sysutil_8h.html#a19eb0a17bd5a89ecbbf7c5d267923402">platform_type</a>();</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span> </div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"><a class="line" href="sysutil_8h.html#aa39de7789fd275dec468bf2543f9c38e">   69</a></span>    std::string <a class="code hl_function" href="sysutil_8h.html#aa39de7789fd275dec468bf2543f9c38e">architecture</a>();</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno">   70</span> </div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"><a class="line" href="sysutil_8h.html#a0802ffda04848c6b280585dd1074c9df">   78</a></span>    std::string <a class="code hl_function" href="sysutil_8h.html#a0802ffda04848c6b280585dd1074c9df">platform_name</a>(<a class="code hl_enumeration" href="sysutil_8h.html#a74208522103f8b280572279e56105242">os_platform</a> type);</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno">   79</span> </div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"><a class="line" href="sysutil_8h.html#a259f8f05fd841bc3c0c225e0c3936fae">   85</a></span>    std::string <a class="code hl_function" href="sysutil_8h.html#a259f8f05fd841bc3c0c225e0c3936fae">cpp_stl_version</a>();</div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno">   86</span> </div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno"><a class="line" href="sysutil_8h.html#ab34a4afb93e8948c1cf525142dd1ec37">   92</a></span>    uint16_t <a class="code hl_function" href="sysutil_8h.html#ab34a4afb93e8948c1cf525142dd1ec37">program_bit</a>();</div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span> </div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"><a class="line" href="sysutil_8h.html#a644ae9daa2b64710b983ef767e1f10ea">   99</a></span>    <a class="code hl_enumeration" href="sysutil_8h.html#aecaf674e04f64f60fd66feab407c606d">endian</a> <a class="code hl_function" href="sysutil_8h.html#a644ae9daa2b64710b983ef767e1f10ea">endian_type</a>();</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"><a class="line" href="sysutil_8h.html#a96eea564b8c9916db1961f755b58829a">  106</a></span>    uint16_t <a class="code hl_function" href="sysutil_8h.html#a96eea564b8c9916db1961f755b58829a">byteswap</a>(uint16_t value);</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"><a class="line" href="sysutil_8h.html#a5cf9adcd67703aa4510e082a125f592f">  113</a></span>    uint32_t <a class="code hl_function" href="sysutil_8h.html#a96eea564b8c9916db1961f755b58829a">byteswap</a>(uint32_t value);</div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno"><a class="line" href="sysutil_8h.html#a8840f1db0653c00e54e802b9e17d2dd6">  120</a></span>    uint64_t <a class="code hl_function" href="sysutil_8h.html#a96eea564b8c9916db1961f755b58829a">byteswap</a>(uint64_t value);</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno"><a class="line" href="sysutil_8h.html#ad2e3f87ac25981420fe10718a4f4276a">  127</a></span>    <span class="keywordtype">void</span> <a class="code hl_function" href="sysutil_8h.html#a96eea564b8c9916db1961f755b58829a">byteswap</a>(uint8_t *data, uint32_t size);</div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno">  128</span> </div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"><a class="line" href="sysutil_8h.html#a200c89e4b9641fc7e73728441699397c">  135</a></span>    <span class="keywordtype">bool</span> <a class="code hl_function" href="sysutil_8h.html#a200c89e4b9641fc7e73728441699397c">system</a>(<span class="keyword">const</span> std::string &amp;cmd);</div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno"><a class="line" href="sysutil_8h.html#a0f0fd47694016b4a0904702508edf58d">  143</a></span>    <span class="keywordtype">bool</span> <a class="code hl_function" href="sysutil_8h.html#a0f0fd47694016b4a0904702508edf58d">callcmd</a>(<span class="keyword">const</span> std::string &amp;cmd, std::string &amp;result);</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"><a class="line" href="sysutil_8h.html#a19b7c742ba00bfbfc133ffd7d3854527">  151</a></span>    std::string <a class="code hl_function" href="sysutil_8h.html#a19b7c742ba00bfbfc133ffd7d3854527">getenv</a>(<span class="keyword">const</span> std::string &amp;name, <span class="keyword">const</span> std::string &amp;default_value);</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno">  152</span> </div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno"><a class="line" href="sysutil_8h.html#ae555d03fceaa9fd502210da3b84d18c5">  158</a></span>    std::string <a class="code hl_function" href="sysutil_8h.html#ae555d03fceaa9fd502210da3b84d18c5">getcwd</a>();</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno">  159</span> </div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno"><a class="line" href="sysutil_8h.html#a78f70eab68b26cda3a2a926b594b8527">  165</a></span>    std::string <a class="code hl_function" href="sysutil_8h.html#a78f70eab68b26cda3a2a926b594b8527">homedir</a>();</div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno">  166</span> </div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno">  167</span>} <span class="comment">// namespace</span></div>
<div class="ttc" id="asysutil_8h_html_a0802ffda04848c6b280585dd1074c9df"><div class="ttname"><a href="sysutil_8h.html#a0802ffda04848c6b280585dd1074c9df">cutl::platform_name</a></div><div class="ttdeci">std::string platform_name(os_platform type)</div><div class="ttdoc">Get the platform name for the current operating system.</div></div>
<div class="ttc" id="asysutil_8h_html_a0f0fd47694016b4a0904702508edf58d"><div class="ttname"><a href="sysutil_8h.html#a0f0fd47694016b4a0904702508edf58d">cutl::callcmd</a></div><div class="ttdeci">bool callcmd(const std::string &amp;cmd, std::string &amp;result)</div><div class="ttdoc">Execute a system command and get the output.</div></div>
<div class="ttc" id="asysutil_8h_html_a19b7c742ba00bfbfc133ffd7d3854527"><div class="ttname"><a href="sysutil_8h.html#a19b7c742ba00bfbfc133ffd7d3854527">cutl::getenv</a></div><div class="ttdeci">std::string getenv(const std::string &amp;name, const std::string &amp;default_value)</div><div class="ttdoc">Get an environment variable.</div></div>
<div class="ttc" id="asysutil_8h_html_a19eb0a17bd5a89ecbbf7c5d267923402"><div class="ttname"><a href="sysutil_8h.html#a19eb0a17bd5a89ecbbf7c5d267923402">cutl::platform_type</a></div><div class="ttdeci">os_platform platform_type()</div><div class="ttdoc">Get the platform type for the current operating system.</div></div>
<div class="ttc" id="asysutil_8h_html_a200c89e4b9641fc7e73728441699397c"><div class="ttname"><a href="sysutil_8h.html#a200c89e4b9641fc7e73728441699397c">cutl::system</a></div><div class="ttdeci">bool system(const std::string &amp;cmd)</div><div class="ttdoc">Execute a system command.</div></div>
<div class="ttc" id="asysutil_8h_html_a259f8f05fd841bc3c0c225e0c3936fae"><div class="ttname"><a href="sysutil_8h.html#a259f8f05fd841bc3c0c225e0c3936fae">cutl::cpp_stl_version</a></div><div class="ttdeci">std::string cpp_stl_version()</div><div class="ttdoc">Get the C++ standard library version.</div></div>
<div class="ttc" id="asysutil_8h_html_a644ae9daa2b64710b983ef767e1f10ea"><div class="ttname"><a href="sysutil_8h.html#a644ae9daa2b64710b983ef767e1f10ea">cutl::endian_type</a></div><div class="ttdeci">endian endian_type()</div><div class="ttdoc">Get the program endianness.</div></div>
<div class="ttc" id="asysutil_8h_html_a74208522103f8b280572279e56105242"><div class="ttname"><a href="sysutil_8h.html#a74208522103f8b280572279e56105242">cutl::os_platform</a></div><div class="ttdeci">os_platform</div><div class="ttdoc">Operating system platform type.</div><div class="ttdef"><b>Definition</b> sysutil.h:44</div></div>
<div class="ttc" id="asysutil_8h_html_a74208522103f8b280572279e56105242a0f8ec0e3af19b871d9014e5109e5072a"><div class="ttname"><a href="sysutil_8h.html#a74208522103f8b280572279e56105242a0f8ec0e3af19b871d9014e5109e5072a">cutl::os_platform::os_unix</a></div><div class="ttdeci">@ os_unix</div></div>
<div class="ttc" id="asysutil_8h_html_a74208522103f8b280572279e56105242a4c7cfa22ccbb49a0418d12bdb8694bfb"><div class="ttname"><a href="sysutil_8h.html#a74208522103f8b280572279e56105242a4c7cfa22ccbb49a0418d12bdb8694bfb">cutl::os_platform::os_windows</a></div><div class="ttdeci">@ os_windows</div></div>
<div class="ttc" id="asysutil_8h_html_a74208522103f8b280572279e56105242a776a1d886fdbbb04b1a8764fd3d41c9e"><div class="ttname"><a href="sysutil_8h.html#a74208522103f8b280572279e56105242a776a1d886fdbbb04b1a8764fd3d41c9e">cutl::os_platform::os_macos</a></div><div class="ttdeci">@ os_macos</div></div>
<div class="ttc" id="asysutil_8h_html_a74208522103f8b280572279e56105242aaf0e42c7c50c918d4570544ca7fad65f"><div class="ttname"><a href="sysutil_8h.html#a74208522103f8b280572279e56105242aaf0e42c7c50c918d4570544ca7fad65f">cutl::os_platform::os_linux</a></div><div class="ttdeci">@ os_linux</div></div>
<div class="ttc" id="asysutil_8h_html_a74208522103f8b280572279e56105242ab6363d75c866dbc9675af5f48ebc1fcc"><div class="ttname"><a href="sysutil_8h.html#a74208522103f8b280572279e56105242ab6363d75c866dbc9675af5f48ebc1fcc">cutl::os_platform::os_unknown</a></div><div class="ttdeci">@ os_unknown</div></div>
<div class="ttc" id="asysutil_8h_html_a78f70eab68b26cda3a2a926b594b8527"><div class="ttname"><a href="sysutil_8h.html#a78f70eab68b26cda3a2a926b594b8527">cutl::homedir</a></div><div class="ttdeci">std::string homedir()</div><div class="ttdoc">Get the home dir for the current user.</div></div>
<div class="ttc" id="asysutil_8h_html_a96eea564b8c9916db1961f755b58829a"><div class="ttname"><a href="sysutil_8h.html#a96eea564b8c9916db1961f755b58829a">cutl::byteswap</a></div><div class="ttdeci">uint16_t byteswap(uint16_t value)</div><div class="ttdoc">Byteswap a 16-bit value.</div></div>
<div class="ttc" id="asysutil_8h_html_aa39de7789fd275dec468bf2543f9c38e"><div class="ttname"><a href="sysutil_8h.html#aa39de7789fd275dec468bf2543f9c38e">cutl::architecture</a></div><div class="ttdeci">std::string architecture()</div><div class="ttdoc">Get the architecture of the cpu processor(or operating system).</div></div>
<div class="ttc" id="asysutil_8h_html_ab34a4afb93e8948c1cf525142dd1ec37"><div class="ttname"><a href="sysutil_8h.html#ab34a4afb93e8948c1cf525142dd1ec37">cutl::program_bit</a></div><div class="ttdeci">uint16_t program_bit()</div><div class="ttdoc">Get the program bit.</div></div>
<div class="ttc" id="asysutil_8h_html_ae555d03fceaa9fd502210da3b84d18c5"><div class="ttname"><a href="sysutil_8h.html#ae555d03fceaa9fd502210da3b84d18c5">cutl::getcwd</a></div><div class="ttdeci">std::string getcwd()</div><div class="ttdoc">Get the working directory of the current excuting process.</div></div>
<div class="ttc" id="asysutil_8h_html_aecaf674e04f64f60fd66feab407c606d"><div class="ttname"><a href="sysutil_8h.html#aecaf674e04f64f60fd66feab407c606d">cutl::endian</a></div><div class="ttdeci">endian</div><div class="ttdoc">Endianness type.</div><div class="ttdef"><b>Definition</b> sysutil.h:32</div></div>
<div class="ttc" id="asysutil_8h_html_aecaf674e04f64f60fd66feab407c606daaae6635e044ac56046b2893a529b5114"><div class="ttname"><a href="sysutil_8h.html#aecaf674e04f64f60fd66feab407c606daaae6635e044ac56046b2893a529b5114">cutl::endian::little</a></div><div class="ttdeci">@ little</div></div>
<div class="ttc" id="asysutil_8h_html_aecaf674e04f64f60fd66feab407c606dad861877da56b8b4ceb35c8cbfdf65bb4"><div class="ttname"><a href="sysutil_8h.html#aecaf674e04f64f60fd66feab407c606dad861877da56b8b4ceb35c8cbfdf65bb4">cutl::endian::big</a></div><div class="ttdeci">@ big</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.10.0
</small></address>
</body>
</html>
